package rc.work.module.bpm.dal.mysql.problem;

import java.util.*;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import rc.work.framework.common.pojo.PageResult;
import rc.work.framework.mybatis.core.query.LambdaQueryWrapperX;
import rc.work.framework.mybatis.core.mapper.BaseMapperX;
import org.apache.ibatis.annotations.Mapper;
import rc.work.module.bpm.controller.admin.problem.vo.ProblemGroupPageReqVO;
import rc.work.module.bpm.dal.dataobject.problem.ProblemGroupDO;

/**
 * 流程实列和问题的关联 Mapper
 *
 * @author A
 */
@Mapper
public interface ProblemGroupMapper extends BaseMapperX<ProblemGroupDO> {

    default PageResult<ProblemGroupDO> selectPage(ProblemGroupPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProblemGroupDO>()
                .eqIfPresent(ProblemGroupDO::getProblemBpmId, reqVO.getProblemBpmId())
                .eqIfPresent(ProblemGroupDO::getInsId, reqVO.getInsId())
                .eqIfPresent(ProblemGroupDO::getResultTable, reqVO.getResultTable())
                .eqIfPresent(ProblemGroupDO::getParams, reqVO.getParams())
                .eqIfPresent(ProblemGroupDO::getGroupId, reqVO.getGroupId())
                .betweenIfPresent(ProblemGroupDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProblemGroupDO::getId));
    }


    /**
     * 执行alter语句
     * @param sql
     * @return
     */
    @Update("${sql}")
    int alter(@Param("sql") String sql);
}